<?php
require_once(APPLICATION_PATH . DIRECTORY_SEPARATOR . 'modules'
        											. DIRECTORY_SEPARATOR . 'cms'
        											. DIRECTORY_SEPARATOR . 'admin'
													. DIRECTORY_SEPARATOR . 'models'
													. DIRECTORY_SEPARATOR . 'Comment.php');
													
class Zend_View_Helper_CommentModule {

    public $view;
	
    public function setView($view) {
        $this->view = $view;
    }

    public function commentModule($position, $index = 0) {
        $this->view->addScriptPath(APPLICATION_PATH . DIRECTORY_SEPARATOR . 'modules'
        											. DIRECTORY_SEPARATOR . 'cms'
        											. DIRECTORY_SEPARATOR . 'public'
        											. DIRECTORY_SEPARATOR . 'views'
        											. DIRECTORY_SEPARATOR . 'scripts');

		
		$auth = Zend_Auth::getInstance();
		$model = new Comment();
		
		$this->view->deal_id = Zend_Controller_Front::getInstance()->getRequest()->getParam('id');
		if($auth->hasIdentity()) {
			$this->view->currentUsername = $auth->getIdentity()->username;
			$this->view->currentFullname = $auth->getIdentity()->fullname;
		} 
		
		if(!is_null($this->view->deal_id)) {
			$this->view->comments = $model->getAllCommentByDealId($this->view->deal_id);
		}
        $this->view->index = $index;
        $this->view->placeholder($position)->captureStart();
        echo $this->view->render('comment.phtml');
        $this->view->placeholder($position)->captureEnd();
    }

}